package com.efounder.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;

import com.efounder.mobilecomps.R;
import com.marlonmafra.android.widget.SegmentedTab;

/**
 * Created by Marcello on 2019/11/12
 * 中间是SegmentedTab 的通用titlebar
 */
public class SegmentedTabTitleBar  extends BaseTitleBar{

    private View centerCustomView;

    public SegmentedTabTitleBar(Context context) {
        this(context,null);
    }

    public SegmentedTabTitleBar(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public SegmentedTabTitleBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void loadAttributesCenterView(TypedArray array) {
    }

    @Override
    protected void initMainCenterViews(Context context) {
        // 初始化中间自定义布局
        centerCustomView = LayoutInflater.from(context).inflate(R.layout.segmented_tab_titlebar_center_view, rlMain, false);
        if (centerCustomView.getId() == View.NO_ID) {
            centerCustomView.setId(generateViewId());
        }
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) centerCustomView.getLayoutParams();
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        rlMain.addView(centerCustomView);
    }
    //获取SegmentedTab
    public SegmentedTab getSegmentedTab(){
        return (SegmentedTab) centerCustomView;
    }
}
